package com.ziyueyuwen.xiniao.enums;

import com.ziyueyuwen.xiniao.util.CalendarUtil;
import org.apache.commons.lang3.StringUtils;

import java.util.Date;

import static com.ziyueyuwen.xiniao.util.ConstUtil.STRING_COURSE_EXPERIENCE;
import static com.ziyueyuwen.xiniao.util.ConstUtil.STRING_COURSE_OPEN;
import static com.ziyueyuwen.xiniao.util.ConstUtil.STRING_COURSE_SHORT_TERM;

/**
 * @author wancheng  on 2019/1/5.
 */
public enum CourseQuarterEnum {
    /**
     * 类型
     */
    COURSE_SPRING("春季课"),
    COURSE_SUMMER("暑假班"),
    COURSE_AUTUMN("秋季课"),
    COURSE_WINTER("寒假班"),
    COURSE_EXPERIENCE("体验课"),
    COURSE_SHORT_TERM("短期课"),
    COURSE_OPEN("公开课"),
    COURSE_OTHER("其他");

    public static CourseQuarterEnum getEnum(Date date,String name){
        if (StringUtils.isNotBlank(name)){
            if ( name.contains(STRING_COURSE_EXPERIENCE)){
                return COURSE_EXPERIENCE;
            }
            if (name.contains(STRING_COURSE_SHORT_TERM)){
                return COURSE_SHORT_TERM;
            }
            if (name.contains(STRING_COURSE_OPEN)){
                return COURSE_OPEN;
            }
        }
        if (date != null){
            if (CalendarUtil.ifSpring(date)){
                return COURSE_SPRING;
            }
            if (CalendarUtil.ifSummer(date)){
                return COURSE_SUMMER;
            }
            if (CalendarUtil.ifAutumn(date)){
                return COURSE_AUTUMN;
            }
            if (CalendarUtil.ifWinter(date)){
                return COURSE_WINTER;
            }
        }
        return COURSE_OTHER;
    }

    private String description;

    CourseQuarterEnum(String description) {
        this.description = description;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }
}
